Skip to contents
## Error in get(paste0(generic, ".", class), envir = get_method_env()) : 
##   object 'type_sum.accel' not found
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Frequencies by state

Continental US A11

state_frequencies <- CensusHLA::census_adjusted_nmdp_hla_frequencies_by_state |> dplyr::filter(allele == 'A*11:01')

out_data <- state_frequencies |>
  dplyr::ungroup() |>
  dplyr::group_by(region, census_region, fips) |>
  dplyr::summarize(gf = sum(us_2020_nmdp_gf))
## `summarise()` has grouped output by 'region', 'census_region'. You can override
## using the `.groups` argument.
gg_state <- usmap::plot_usmap(
  data = out_data,
  regions = "states",
  #exclude = c('Alaksa','Hawaii'),
  exclude = c('AK', 'HI'),
  values = "gf",
  color = "black",
  linewidth = 0.1
) +
  viridis::scale_fill_viridis(option = "plasma", direction = 1)
out_data |>
DT::datatable(
  ,filter = 'top'
  ,rownames = FALSE
  ,extensions = 'Buttons', options = list(
    scrollX=TRUE,
    pageLength = 10,
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'colvis')
    )
  )

Alaska and Hawaii US A11 frequencies

ak <-
  CensusHLA::census_adjusted_nmdp_hla_frequencies_by_county |> dplyr::filter(state == 'Alaska' &
                                                                               allele == 'A*11:01')
hi <-
  CensusHLA::census_adjusted_nmdp_hla_frequencies_by_county |> dplyr::filter(state == 'Hawaii' &
                                                                               allele == 'A*11:01')

state_county_frequencies <- rbind(ak, hi)

out_data <- state_county_frequencies |>
  dplyr::ungroup() |>
  dplyr::filter(allele == 'A*11:01') |>
  dplyr::group_by(region, state, census_region, county, fips, loci, allele) |>
  dplyr::summarize(us_2020_nmdp_gf_sum = sum(us_2020_nmdp_gf)) |>
  dplyr::filter(!(is.na(us_2020_nmdp_gf_sum))) |>
  # Create a STATEFP and COUNTYFP column by breaking the fips column on the 3rd character to the end
  dplyr::mutate(STATEFP = substr(fips, 1, 2),
                COUNTYFP = substr(fips, 3, nchar(fips)))
## `summarise()` has grouped output by 'region', 'state', 'census_region',
## 'county', 'fips', 'loci'. You can override using the `.groups` argument.
gg_ak_and_hi <- usmap::plot_usmap(
  data = out_data,
  regions = "counties",
  #exclude = c('Alaksa','Hawaii'),
  include = c('AK', 'HI'),
  values = "us_2020_nmdp_gf_sum",
  color = "black",
  linewidth = 0.1
) +
  viridis::scale_fill_viridis(option = "plasma", direction = 1)
gg_ak_and_hi

County Maps

make_state_by_county_allele_frequency_map(
  state_name = 'Texas',
  query_allele = 'A*11:01'
)
## Reading layer `tl_2020_us_county' from data source 
##   `/tmp/Rtmpt6zK6y/temp_libpath849b13299ee5/CensusHLA/extdata/tiger_2020/county/tl_2020_us_county.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 3234 features and 17 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -179.2311 ymin: -14.60181 xmax: 179.8597 ymax: 71.43979
## Geodetic CRS:  NAD83
## Joining with `by = join_by(STATEFP, COUNTYFP)`
## $out_data
## # A tibble: 254 × 26
## # Groups:   region, state, census_region, county, fips, loci [254]
##    region state census_region      county fips  loci  allele us_2020_nmdp_gf_sum
##    <chr>  <chr> <chr>              <chr>  <chr> <chr> <chr>                <dbl>
##  1 us     Texas Anderson County, … Ander… 48001 A     A*11:…              0.0936
##  2 us     Texas Andrews County, T… Andre… 48003 A     A*11:…              0.101 
##  3 us     Texas Angelina County, … Angel… 48005 A     A*11:…              0.0976
##  4 us     Texas Aransas County, T… Arans… 48007 A     A*11:…              0.111 
##  5 us     Texas Archer County, Te… Arche… 48009 A     A*11:…              0.112 
##  6 us     Texas Armstrong County,… Armst… 48011 A     A*11:…              0.113 
##  7 us     Texas Atascosa County, … Atasc… 48013 A     A*11:…              0.0988
##  8 us     Texas Austin County, Te… Austi… 48015 A     A*11:…              0.102 
##  9 us     Texas Bailey County, Te… Baile… 48017 A     A*11:…              0.0976
## 10 us     Texas Bandera County, T… Bande… 48019 A     A*11:…              0.110 
## # ℹ 244 more rows
## # ℹ 18 more variables: STATEFP <chr>, COUNTYFP <chr>, COUNTYNS <chr>,
## #   GEOID <chr>, NAME <chr>, NAMELSAD <chr>, LSAD <chr>, CLASSFP <chr>,
## #   MTFCC <chr>, CSAFP <chr>, CBSAFP <chr>, METDIVFP <chr>, FUNCSTAT <chr>,
## #   ALAND <dbl>, AWATER <dbl>, INTPTLAT <chr>, INTPTLON <chr>,
## #   geometry <MULTIPOLYGON [°]>
## 
## $p1

out_data |>
DT::datatable(
  ,filter = 'top'
  ,rownames = FALSE
  ,extensions = 'Buttons', options = list(
    scrollX=TRUE,
    pageLength = 10,
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'colvis')
    )
  )

H3 Hexagons

MA

(state_info <- query_state_codes())
##    STATE STATEFP STATENS                                   STATE_NAME
## 1     AL      01 1779775                                      Alabama
## 2     AK      02 1785533                                       Alaska
## 3     AZ      04 1779777                                      Arizona
## 4     AR      05   68085                                     Arkansas
## 5     CA      06 1779778                                   California
## 6     CO      08 1779779                                     Colorado
## 7     CT      09 1779780                                  Connecticut
## 8     DE      10 1779781                                     Delaware
## 9     DC      11 1702382                         District of Columbia
## 10    FL      12  294478                                      Florida
## 11    GA      13 1705317                                      Georgia
## 12    HI      15 1779782                                       Hawaii
## 13    ID      16 1779783                                        Idaho
## 14    IL      17 1779784                                     Illinois
## 15    IN      18  448508                                      Indiana
## 16    IA      19 1779785                                         Iowa
## 17    KS      20  481813                                       Kansas
## 18    KY      21 1779786                                     Kentucky
## 19    LA      22 1629543                                    Louisiana
## 20    ME      23 1779787                                        Maine
## 21    MD      24 1714934                                     Maryland
## 22    MA      25  606926                                Massachusetts
## 23    MI      26 1779789                                     Michigan
## 24    MN      27  662849                                    Minnesota
## 25    MS      28 1779790                                  Mississippi
## 26    MO      29 1779791                                     Missouri
## 27    MT      30  767982                                      Montana
## 28    NE      31 1779792                                     Nebraska
## 29    NV      32 1779793                                       Nevada
## 30    NH      33 1779794                                New Hampshire
## 31    NJ      34 1779795                                   New Jersey
## 32    NM      35  897535                                   New Mexico
## 33    NY      36 1779796                                     New York
## 34    NC      37 1027616                               North Carolina
## 35    ND      38 1779797                                 North Dakota
## 36    OH      39 1085497                                         Ohio
## 37    OK      40 1102857                                     Oklahoma
## 38    OR      41 1155107                                       Oregon
## 39    PA      42 1779798                                 Pennsylvania
## 40    RI      44 1219835                                 Rhode Island
## 41    SC      45 1779799                               South Carolina
## 42    SD      46 1785534                                 South Dakota
## 43    TN      47 1325873                                    Tennessee
## 44    TX      48 1779801                                        Texas
## 45    UT      49 1455989                                         Utah
## 46    VT      50 1779802                                      Vermont
## 47    VA      51 1779803                                     Virginia
## 48    WA      53 1779804                                   Washington
## 49    WV      54 1779805                                West Virginia
## 50    WI      55 1779806                                    Wisconsin
## 51    WY      56 1779807                                      Wyoming
## 52    AS      60 1802701                               American Samoa
## 53    GU      66 1802705                                         Guam
## 54    MP      69 1779809 Commonwealth of the Northern Mariana Islands
## 55    PR      72 1779808                                  Puerto Rico
## 56    UM      74 1878752                  U.S. Minor Outlying Islands
## 57    VI      78 1802710                 United States Virgin Islands
ms_4 <-
  summarize_tract_genotypic_frequencies_by_h3_hexagon(
    state_abbreviation = 'MS',
    query_allele = 'B*58:01',
    h3_resolution = 4
  )
## INFO [2025-04-22 19:49:19] Working with state: MS
## Adding missing grouping variables: `census_region`
## Reading layer `tl_2020_28_tract' from data source 
##   `/tmp/Rtmpt6zK6y/temp_libpath849b13299ee5/CensusHLA/extdata/tiger_2020/tract/tl_2020_28_tract.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 878 features and 12 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -91.65501 ymin: 30.13984 xmax: -88.09789 ymax: 34.9961
## Geodetic CRS:  NAD83
## INFO [2025-04-22 19:49:26] Working with state: MS
## Data has been transformed to EPSG:4326.
## Warning: st_centroid assumes attributes are constant over geometries
## Data has been transformed to EPSG:4326.
## Joining with `by = join_by(nmdp_race_code)`
ms_4$p1

Within County

San Francisco, CA

ca_francisco <- make_county_census_tract_allele_frequency_map(
  state_abbreviation = 'CA',
  query_allele = 'A*11:01',
  county_code = '075',
  county_name = 'San Francisco County'
)
## INFO [2025-04-22 19:49:45] Working with state: CA
## Adding missing grouping variables: `census_region`
## Reading layer `tl_2020_06_tract' from data source 
##   `/tmp/Rtmpt6zK6y/temp_libpath849b13299ee5/CensusHLA/extdata/tiger_2020/tract/tl_2020_06_tract.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 9129 features and 12 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -124.482 ymin: 32.52883 xmax: -114.1312 ymax: 42.0095
## Geodetic CRS:  NAD83
ca_francisco
## $out_data
## # A tibble: 241 × 19
## # Groups:   region, state, county, tract, tract_name, loci [241]
##    region state county tract  tract_name             loci  allele total_2020_pop
##    <chr>  <chr> <chr>  <chr>  <chr>                  <chr> <chr>           <dbl>
##  1 us     06    075    010101 Census Tract 101.01, … A     A*11:…           1988
##  2 us     06    075    010102 Census Tract 101.02, … A     A*11:…           1974
##  3 us     06    075    010201 Census Tract 102.01, … A     A*11:…           2431
##  4 us     06    075    010202 Census Tract 102.02, … A     A*11:…           2034
##  5 us     06    075    010300 Census Tract 103, San… A     A*11:…           4006
##  6 us     06    075    010401 Census Tract 104.01, … A     A*11:…           2189
##  7 us     06    075    010402 Census Tract 104.02, … A     A*11:…           2257
##  8 us     06    075    010500 Census Tract 105, San… A     A*11:…           3181
##  9 us     06    075    010600 Census Tract 106, San… A     A*11:…           3667
## 10 us     06    075    010701 Census Tract 107.01, … A     A*11:…           3701
## # ℹ 231 more rows
## # ℹ 11 more variables: us_2020_nmdp_gf_sum <dbl>, GEOID <chr>, NAME <chr>,
## #   NAMELSAD <chr>, MTFCC <chr>, FUNCSTAT <chr>, ALAND <dbl>, AWATER <dbl>,
## #   INTPTLAT <chr>, INTPTLON <chr>, geometry <MULTIPOLYGON [°]>
## 
## $p1

By Cancer Center catchment area

A11

gg_catchment <- plot_delNero2022_catchment_areas(
  query_allele = 'A*11:01',
  CensusHLA::a11_catchment_summed$sf_tract_centroids_for_all_states_with_catchment_with_us_population_race_code_percentages_by_tract_summed
)
## Warning in layer_sf(geom = GeomSf, data = data, mapping = mapping, stat = stat,
## : Ignoring unknown parameters: `line`
CensusHLA::a11_catchment_summed$sf_tract_centroids_for_all_states_with_catchment_with_us_population_race_code_percentages_by_tract_summed |> dplyr::select(-geometry) |> dplyr::mutate(patient_pop = total_2020_pop * us_2020_nmdp_gf_sum) |>  dplyr::arrange(desc(patient_pop)) |> DT::datatable(
  ,filter = 'top'
  ,rownames = FALSE
  ,extensions = 'Buttons', options = list(
    scrollX=TRUE,
    pageLength = 10,
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'colvis')
    )
  )
## Warning in instance$preRenderHook(instance): It seems your data is too big for
## client-side DataTables. You may consider server-side processing:
## https://rstudio.github.io/DT/server.html

System and Session info

## R version 4.4.1 (2024-06-14)
## Platform: x86_64-pc-linux-gnu
## Running under: Rocky Linux 9.4 (Blue Onyx)
## 
## Matrix products: default
## BLAS/LAPACK: FlexiBLAS OPENBLAS-OPENMP;  LAPACK version 3.9.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: UTC
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] dplyr_1.1.4          ggplot2_3.5.1        CensusHLA_0.1.0.9000
## 
## loaded via a namespace (and not attached):
##  [1] gtable_0.3.6                  xfun_0.49                    
##  [3] bslib_0.8.0                   htmlwidgets_1.6.4            
##  [5] tigris_2.1                    vctrs_0.6.5                  
##  [7] tools_4.4.1                   crosstalk_1.2.1              
##  [9] generics_0.1.3                curl_6.0.1                   
## [11] tibble_3.2.1                  proxy_0.4-27                 
## [13] pkgconfig_2.0.3               KernSmooth_2.23-26           
## [15] desc_1.4.3                    uuid_1.2-1                   
## [17] lifecycle_1.0.4               h3jsr_1.3.1                  
## [19] compiler_4.4.1                farver_2.1.2                 
## [21] stringr_1.5.1                 textshaping_0.4.1            
## [23] munsell_0.5.1                 terra_1.8-5                  
## [25] codetools_0.2-20              htmltools_0.5.8.1            
## [27] class_7.3-23                  sass_0.4.9                   
## [29] yaml_2.3.10                   tidyr_1.3.1                  
## [31] pillar_1.10.0                 pkgdown_2.1.1                
## [33] jquerylib_0.1.4               classInt_0.4-10              
## [35] DT_0.33                       cachem_1.1.0                 
## [37] wk_0.9.4                      viridis_0.6.5                
## [39] tidyselect_1.2.1              digest_0.6.37                
## [41] censusapi_0.8.0               stringi_1.8.4                
## [43] purrr_1.0.4                   sf_1.0-19                    
## [45] labeling_0.4.3                rnaturalearth_1.0.1          
## [47] fastmap_1.2.0                 grid_4.4.1                   
## [49] colorspace_2.1-1              cli_3.6.4                    
## [51] magrittr_2.0.3                utf8_1.2.4                   
## [53] e1071_1.7-16                  withr_3.0.2                  
## [55] scales_1.3.0                  rappdirs_0.3.3               
## [57] lambda.r_1.2.4                rmarkdown_2.29               
## [59] httr_1.4.7                    gridExtra_2.3                
## [61] futile.logger_1.4.3           rnaturalearthhires_1.0.0.9000
## [63] ragg_1.3.3                    evaluate_1.0.1               
## [65] knitr_1.49                    V8_6.0.0                     
## [67] viridisLite_0.4.2             s2_1.1.7                     
## [69] futile.options_1.0.1          rlang_1.1.5                  
## [71] usmap_0.7.1                   Rcpp_1.0.13-1                
## [73] glue_1.8.0                    DBI_1.2.3                    
## [75] geojsonsf_2.0.3               formatR_1.14                 
## [77] rstudioapi_0.17.1             usmapdata_0.3.0              
## [79] jsonlite_1.8.9                R6_2.5.1                     
## [81] systemfonts_1.1.0             fs_1.6.5                     
## [83] units_0.8-5
##                                               sysname 
##                                               "Linux" 
##                                               release 
##                        "5.14.0-427.22.1.el9_4.x86_64" 
##                                               version 
## "#1 SMP PREEMPT_DYNAMIC Wed Jun 19 17:35:04 UTC 2024" 
##                                              nodename 
##         "ip-10-110-10-102.us-west-2.compute.internal" 
##                                               machine 
##                                              "x86_64" 
##                                                 login 
##                                             "unknown" 
##                                                  user 
##                                       "christian.roy" 
##                                        effective_user 
##                                       "christian.roy"